package filter;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

public class HandlerDel extends Handler {

	HandlerDel(Filter filter){
		super(filter);
	}
	
	@Override
	public void doCmd(String path) throws Exception {
		if(!(path.split(" ").length == 1)) {
			this.cmdError();
			throw new IOException(ErrorMessage);
		}
		
		if(new File(path).exists()) {
			filtOperation.delFile(path);
			System.out.println("Delete Completed ");
		} else {
			this.fileError();
			throw new FileNotFoundException(ErrorMessage);
		}
	}

	@Override
	public void doTips() {
		System.out.println("Format : -del [path]	\n"
				+ "				For delete the file on the path\n"
				+ "				if the file is a directory, delete it all\n");
	}
}
